<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:composition template="/templates/template-menu.xhtml">
		
		<ui:define name="scripts">

			<script type="text/javascript">
				function inibir(){
					jQuery("#id-ramo").bind("keypress",function(e){
							e.preventDefault();
						});
					}
			</script>
			
			<style type="text/css">
				.rich-messages-label{
					font-weight:bold;
				}
			</style>

		</ui:define>

	<ui:define name="body">
	
		<rich:panel style="800px;">
	
			<f:facet name="header">
				<h:outputLabel value="Ramo (Atividade Econômica)" style="FONT-SIZE: small; FONT-FAMILY: 'SansSerif';"/>
			</f:facet>
	
			<h:form id="formulario-dados" prependId="false">
	
				<h:panelGrid columns="2">
					
					<h:outputLabel value="Id:" style="FONT-SIZE: medium; FONT-FAMILY: 'SansSerif';"/>
					<h:inputText id="id-ramo" value="#{ramoController.ramo.idRamo}"
						style="width:50px;" />
	
					<h:outputLabel value="Nome:" style="FONT-SIZE: medium; FONT-FAMILY: 'SansSerif';"/>
					<h:inputText id="nome-ramo" style="width:300px" onkeypress="this.style.textTransform = 'uppercase';" value="#{ramoController.ramo.nomeRamo}" />
	
				</h:panelGrid>
	
				<rich:spacer width="100%" height="10px" />
	
				<h:commandButton value="Salvar"
					actionListener="#{ramoController.salvar}" style="FONT-SIZE: medium; FONT-FAMILY: 'SansSerif'; width:100px;"/>
					
				<rich:messages>
					 <f:facet name="errorMarker">
            			<h:graphicImage url="/imagens/alerta.png"/>
     				 </f:facet>

      				<f:facet name="infoMarker">
			            <h:graphicImage url="/imagens/ok.png"/>
				    </f:facet>
				</rich:messages>
	
			</h:form>
	
			<rich:spacer width="100%" height="10px" />
	
			<rich:separator width="100%" height="10px;" />
	
			<rich:spacer width="100%" height="10px" />
	
			<a4j:form id="formulario-tabela" prependId="false" >
				<rich:dataTable id="tabela" value="#{ramoController.lista}"
					var="ramo" style="width:100%;">
	
					<rich:column width="50">
						<div id="div-id" align="center">
							<f:facet name="header">
								<h:outputLabel value="ID" />
							</f:facet>
	
							<h:outputLabel value="#{ramo.id}" />
						</div>
					</rich:column>
	
					<rich:column width="500">
						<div id="div-nome" align="center">
							<f:facet name="header">
								<h:outputLabel value="Nome" />
							</f:facet>
	
							<h:outputLabel value="#{ramo.nome}" />
						</div>
					</rich:column>
	
					<rich:column width="50">
	
						<f:facet name="header">
							<h:outputLabel value="Alterar" />
						</f:facet>
						
						<div align="center">
							<h:panelGrid columns="3">
							<a4j:commandButton value="Alterar" image="/imagens/editar.png"
								actionListener="#{ramoController.carregarRegistro}"
								oncomplete="inibir();" reRender="formulario-dados" process="formulario-dados" immediate="true" ajaxSingle="true">
								<a4j:actionparam name="idRamo" value="#{ramo.id}"/>
							</a4j:commandButton>
							
							<rich:spacer width="10px"/>
							
							<a4j:commandButton value="Excluir" image="/imagens/delete.png"
								actionListener="#{ramoController.excluirRegistro}" reRender="formulario-tabela,formulario-dados" process="formulario-tabela,formulario-dados" immediate="true" ajaxSingle="true">
								<a4j:actionparam name="idRamo" value="#{ramo.id}" />
							</a4j:commandButton>
							</h:panelGrid>
						</div>
						
					</rich:column>
	
				</rich:dataTable>
			</a4j:form>
		</rich:panel>
	</ui:define>
	</ui:composition>
</html>
